Namespace DB

    Module mDatabase

        Public WithEvents AccountDB As cDataBase
        Public WithEvents GameDB As cDataBase

        Public Function ConnectDatabase(ByVal sSource As String, ByVal sUser As String, ByVal sPass As String, ByVal iConnections As Integer) As Boolean

            Try

                AccountDB = New cDataBase(sSource, sUser, sPass, iConnections)

                AccountDB.CheckDatabase("Account")
                AccountDB.UseDatabase("Account")

                GameDB = New cDataBase(sSource, sUser, sPass, iConnections)

                GameDB.CheckDatabase("GameEvo")
                GameDB.UseDatabase("GameEvo")

                Return True

            Catch ex As System.Data.SqlClient.SqlException

                Return False

            End Try

        End Function

        Public Sub Shutdown()

            If Not AccountDB Is Nothing Then
                AccountDB.Shutdown()
                AccountDB = Nothing
            End If

            If Not GameDB Is Nothing Then
                GameDB.Shutdown()
                GameDB = Nothing
            End If

        End Sub

        Private Sub AccountDB_WriteConsoleLine(ByVal strText As String) Handles AccountDB.WriteConsoleLine
            Output.AddLine("\B0\F1DB>\F0\B8 " & strText)
        End Sub

        Private Sub GameDB_WriteConsoleLine(ByVal strText As String) Handles GameDB.WriteConsoleLine
            Output.AddLine("\B0\F1DB>\F0\B8 " & strText)
        End Sub

    End Module

End Namespace